<template>
	<view class="master" v-for="(i, index) in masterList" :key="index">
		<uni-section :title="i.name" class="section" type="line text"></uni-section>
		<view v-for="(item, index) in i.child" :key="index">
			<uni-list class="" :border="false">
				<uni-list-item :title="item.name" :to="item.url" link v-if="item.isShow"></uni-list-item>
			</uni-list>
		</view>
	</view>
</template>

<script setup>
import { reactive, ref } from 'vue';
import { onShow } from '@dcloudio/uni-app';
const masterList = reactive([
	{
		name: '分类管理',
		child: [
			{
				name: '管理分类',
				url: '/pages_main/index/creategoxy',
				isShow: false
			}
		]
	},
	{
		name: '商品管理',
		child: [
			{
				name: '商品列表',
				url: '/pages_main/index/goodList',
				isShow: false
			},
			{
				name: '新增商品',
				url: '/pages_main/goods/editGoods',
				isShow: false
			},
			{
				name: '订单列表',
				url: '/pages/ucenter/order/list?role=admin',
				isShow: false
			}
		]
	},
	{
		name: '关于买家',
		child: [
			{
				name: '商家信息',
				url: '/pages_main/brand/brand',
				isShow: true
			}
		]
	}
]);
const brandObj = uniCloud.importObject('mall-brand');
const showMuen = ref(false);
const getBrandmsg = async () => {
	let res = await brandObj.get();
	if (res.data.length > 0) {
		uni.setStorageSync('brand_id', res.data[0]._id);
		masterList.forEach((i) => {
			i.child.forEach((j) => {
				j.isShow = true;
			});
		});
	}
	console.log(showMuen.value);
};
onShow(() => {
	getBrandmsg();
});
</script>

<style lang="scss" scoped>
.master {
	padding: 0;
	margin: 0;
	box-sizing: #fff;

	.section {
		margin: 0;
		background-color: #fff;
	}
}
</style>
